using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class WeaponManager {
	
	static string typeName = "WeaponItem";
	
	static GenericManager<WeaponItem> _m;
	static GenericManager<WeaponItem> m
	{
		get
		{
			if(_m == null)
				_m = new GenericManager<WeaponItem>(typeName);
			return _m;
		}
	}
	
	public static Dictionary<string,string> index
	{
		get
		{
			return m.index;
		}
	}
	
	public static WeaponItem Load(string name)
	{
		return m.LoadObject(name);
	}
	
	public static bool isCustom(string name)
	{
		return m.isCustom(name);
	}
		
	public static WeaponItem AddItem(string name, string description, float weight, 
		List<BuffDebuff> buffs, float worth = 0, int damageDice = 1, int dieType = 8, 
		int threatRange = 20, int critMult = 2, bool twoHanded = false, bool lightWeapon = false, 
		bool rangedWeapon = false, int rangeIncrement = 10, bool requiresAmmo = false, 
		string DamageType = "B", bool hideInventory = false, bool hasCharges = false, 
		int chargesRemaining = 50)
	{
		WeaponItem a = new WeaponItem();
		a.name = name;
		a.dieCount = damageDice;
		a.dieType = dieType;
		a.critBounds = threatRange;
		a.critMultiplier = critMult;
		a.TwoHanded = twoHanded;
		a.LightWeapon = lightWeapon;
		a.Ranged = rangedWeapon;
		a.RangeIncrement = rangeIncrement;
		a.RequiresAmmunition = requiresAmmo;
		a.DamageType = DamageType;
		a.DontShowInInventory = hideInventory;
		a.HasCharges = hasCharges;
		a.chargesRemaining = chargesRemaining;
		a.description = description;
		a.weight = weight;
		a.buffs = buffs;
		a.worth = worth;
		a.quantity = 1;
		a.HasCharges = hasCharges;
		a.chargesRemaining = chargesRemaining;
		
		return m.AddObject(a);
	}
	
	public static bool SaveItem(WeaponItem s, string file)
	{
		return m.SaveObject(s, file);
	}
	
	public static void DeleteItem(string name)
	{
		m.DeleteObject(name);
	}
}
